<?
require("config.php");

$location_status .= " | Edit";

$show_backnav = "menu";

require($rela_path . "bin/country.php");

$menutype = 2;

if (NULL!=$action){

	$dir = "$table/";

	myUpload($Picture1,$Picture1_name,$dir);
	myUpload($Picture2,$Picture2_name,$dir);
	myUpload($Picture3,$Picture3_name,$dir);
	myUpload($Picture4,$Picture4_name,$dir);

	if ($Picture1_name==NULL) $Picture1_name=$bk_Picture1;
	if ($Picture2_name==NULL) $Picture2_name=$bk_Picture2;
	if ($Picture3_name==NULL) $Picture3_name=$bk_Picture3;
	if ($Picture4_name==NULL) $Picture4_name=$bk_Picture4;

	if ($remove_Picture1=="ture") $Picture1_name=NULL;
	if ($remove_Picture2=="ture") $Picture2_name=NULL;
	if ($remove_Picture3=="ture") $Picture3_name=NULL;
	if ($remove_Picture4=="ture") $Picture4_name=NULL;


   $field = array(
	"code",
	"trainer",
	"date",
	"name",
	"details",
	"picture1",
	"picture2",
	"picture3",
	"picture4",
    "status",
	"publish_date",
	);


   $content = array(
	$Code,
	$Trainer,
	"$Year-$Month-$Day",
	$Name,
	$Details,
	$Picture1_name,
	$Picture2_name,
	$Picture3_name,
	$Picture4_name,
	$Status,
	"$myYear-$myMonth-$myDay",
	);

   $exp = "id='$id'";

   myUpdate($table,$field,$content,$exp);


   header("location:" . $rela_path . "share/msg.php?v=7222&label=" . $Trainer);

   exit();

}


$Query = "select 
	code,
	trainer,
	date,
	name,
details,
picture1,
picture2,
picture3,
picture4,
status,
publish_date 
from $table where id='$id' Limit 1";
$r = myQuery($Query);




	$Code=		$r[0][0];
	$Trainer=	$r[0][1];
	$Date=	$r[0][2];
	$Name=	$r[0][3];
$Details=$r[0][4];
$Picture1=$r[0][5];
$Picture2=$r[0][6];
$Picture3=$r[0][7];
$Picture4=$r[0][8];
$Status=$r[0][9];
$Publish_date=$r[0][10];

require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>

<form action="" method="post" enctype="multipart/form-data" name="form1">
<!--hidden filed-->
<input name="action" type="hidden" value="edit">
<input name="Code" type="hidden" value="<?print($Code)?>">


<input name="bk_Picture1" type="hidden" value="<?print($Picture1)?>">
<input name="bk_Picture2" type="hidden" value="<?print($Picture2)?>">
<input name="bk_Picture3" type="hidden" value="<?print($Picture3)?>">
<input name="bk_Picture4" type="hidden" value="<?print($Picture4)?>">

  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image" type="image" onclick="Redirect('menu.php?label=<?=$label?>',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image" type="image" src="../../images/bt_save.gif" width="76" height="22"  <?print($active)?>> 
      </td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right">&nbsp; </td>
    </tr>
    <tr> 
      <td><table border="0">
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code :</td>
            <td> <?print($Code)?>  </td>
          </tr>

          <tr> 
            <td class="tdheader">Trainer :</td>
            <td>
			
<?
/*
if ($label){

	echo $label;
	echo "<input type=\"hidden\" name=\"Trainer\" value=\"$label\">";

}else{
*/

$Query = "select name from course_trainer_info";
$r = myQuery($Query);

$sourceData = array();

for ($i=0;$i<count($r);$i++){

	array_push($sourceData,$r[$i][0]);

	}


FFPSelectBox("Trainer",$Trainer,$sourceData,$sourceLabel);
//}
?>  			
			
            </td>
          </tr>

          <tr> 
            <td class="tdheader">Date :</td>
            <td> <?=FFPdate($Date)?> 
            </td>
          </tr>

          <tr> 
            <td class="tdheader">Title :</td>
            <td> <textarea class="text" name="Name" cols="60" rows="5"><?=$Name?></textarea>
            </td>
          </tr>
          <tr> 
            <td class="tdheader">Details : </td>
            <td><textarea class="text" name="Details" cols="60" rows="20"><?print($Details)?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Picture 1:</td>
            <td><?loadImage($Picture1,$rela_path . $PIC_DIR. $table . "/")?>
			<?removeImage($Picture1,"remove_Picture1")?>
			<input type="file" class="text" name="Picture1" size="45"> 
			
			</td>
          </tr>

          <tr> 
            <td class="tdheader">Picture 2:</td>
            <td><?loadImage($Picture2,$rela_path . $PIC_DIR. $table . "/")?>
			<?removeImage($Picture2,"remove_Picture2")?>
			<input type="file" class="text" name="Picture2" size="45"> 
			
			</td>
          </tr>

          <tr> 
            <td class="tdheader">Picture 3:</td>
            <td><?loadImage($Picture3,$rela_path . $PIC_DIR. $table . "/")?>
			<?removeImage($Picture3,"remove_Picture3")?>
			<input type="file" class="text" name="Picture3" size="45"> 
			
			</td>
          </tr>



          <tr> 
            <td class="tdheader">Picture 4:</td>
            <td><?loadImage($Picture4,$rela_path . $PIC_DIR. $table . "/")?>
			<?removeImage($Picture4,"remove_Picture3")?>
			<input type="file" class="text" name="Picture4" size="45"> 
			
			</td>
          </tr>



          <tr> 
            <td class="tdheader">Publish :</td>
            <td> 
              <?

$sourceData = array(
  "Yes",
  "No",
  );

$boxName="Status";

$value=$Status;

FFPCheckBox("Status",$Status,$sourceData,$sourceLabel);

?>
          </tr>
          <tr> 
            <td class="tdheader">Publishing Date : </td>
            <td><?print(FFPtime($Publish_date))?></td>
          </tr> 
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image2" type="image" onclick="Redirect('menu.php?label=<?=$label?>',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image2" type="image" src="../../images/bt_save.gif" width="76" height="22" <?print($active)?>> 
      </td>
    </tr>
  </table>
</form>
<?
require($rela_path . "inc/footer.php");
?>

